package com.lelouch.examplecode.designpattern.factory.factorymethod;

import com.lelouch.examplecode.designpattern.factory.bean.MengNiu;
import com.lelouch.examplecode.designpattern.factory.bean.Telunsu;
import com.lelouch.examplecode.designpattern.factory.bean.Yili;
import com.lelouch.examplecode.designpattern.factory.bean.Milk;

/**
 * 简单工厂模式
 *
 * @author lcy
 * @create 2018-08-02 19:47
 */
public class SimpleFactory {

    //不符合关闭开放原则，如有新的牛奶的话就要修改代码
    public Milk getMilk(String name){
        if("伊利".equals(name)){
            return new Yili();
        }else if("蒙牛".equals(name)){
            return new MengNiu();
        }else if("特仑苏".equals(name)){
            return new Telunsu();
        }else{
            System.out.println("没有你指定的牛奶！");
            return null;
        }
    }
}
